package com.appwoo.txtws.component;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class LocalHelper extends SQLiteOpenHelper
{
  private static final int version = 2;
  private Context mContext;
  private SQLiteDatabase mdb = null;

  public LocalHelper(Context paramContext)
  {
    super(paramContext, "db_time", null, 2);
    this.mContext = paramContext;
  }

  // ERROR //
  public void addSenior(String paramString1, String paramString2, String paramString3, String paramString4)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   4: ifnonnull +125 -> 129
    //   7: aload_0
    //   8: aload_0
    //   9: invokevirtual 30	com/appwoo/txtws/component/LocalHelper:getWritableDatabase	()Landroid/database/sqlite/SQLiteDatabase;
    //   12: putfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   15: new 32	java/lang/StringBuilder
    //   18: dup
    //   19: aload_2
    //   20: invokestatic 38	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   23: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   26: ldc 43
    //   28: invokevirtual 47	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   31: invokevirtual 51	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   34: astore 5
    //   36: new 32	java/lang/StringBuilder
    //   39: dup
    //   40: aload_3
    //   41: invokestatic 38	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   44: invokespecial 41	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   47: ldc 43
    //   49: invokevirtual 47	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   52: invokevirtual 51	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   55: astore 6
    //   57: new 53	android/content/ContentValues
    //   60: dup
    //   61: invokespecial 56	android/content/ContentValues:<init>	()V
    //   64: astore 7
    //   66: aload 7
    //   68: ldc 58
    //   70: aload_1
    //   71: invokevirtual 62	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   74: aload 7
    //   76: ldc 64
    //   78: aload 5
    //   80: invokevirtual 62	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   83: aload 7
    //   85: ldc 66
    //   87: aload 6
    //   89: invokevirtual 62	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   92: aload 7
    //   94: ldc 68
    //   96: aload 4
    //   98: invokevirtual 62	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   101: aload_0
    //   102: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   105: ldc 70
    //   107: aconst_null
    //   108: aload 7
    //   110: invokevirtual 76	android/database/sqlite/SQLiteDatabase:insertOrThrow	(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J
    //   113: pop2
    //   114: aload_0
    //   115: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   118: ifnull +10 -> 128
    //   121: aload_0
    //   122: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   125: invokevirtual 79	android/database/sqlite/SQLiteDatabase:close	()V
    //   128: return
    //   129: aload_0
    //   130: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   133: invokevirtual 79	android/database/sqlite/SQLiteDatabase:close	()V
    //   136: aload_0
    //   137: aload_0
    //   138: invokevirtual 30	com/appwoo/txtws/component/LocalHelper:getWritableDatabase	()Landroid/database/sqlite/SQLiteDatabase;
    //   141: putfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   144: goto -129 -> 15
    //   147: astore 9
    //   149: aload_0
    //   150: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   153: ifnull -25 -> 128
    //   156: aload_0
    //   157: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   160: invokevirtual 79	android/database/sqlite/SQLiteDatabase:close	()V
    //   163: return
    //   164: astore 8
    //   166: aload_0
    //   167: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   170: ifnull +10 -> 180
    //   173: aload_0
    //   174: getfield 20	com/appwoo/txtws/component/LocalHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   177: invokevirtual 79	android/database/sqlite/SQLiteDatabase:close	()V
    //   180: aload 8
    //   182: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   101	114	147	java/lang/Exception
    //   101	114	164	finally
  }

  public void delData()
  {
    try
    {
      if ((this.mdb == null) || (!this.mdb.isOpen()))
        this.mdb = getWritableDatabase();
      this.mdb.delete("t_senior", null, null);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
    }
  }

  public int isSeniorNull(String paramString)
  {
    int i = 0;
    try
    {
      SQLiteDatabase localSQLiteDatabase = this.mdb;
      i = 0;
      if (localSQLiteDatabase == null)
        this.mdb = getReadableDatabase();
      boolean bool = this.mdb.isOpen();
      i = 0;
      if (!bool)
        this.mdb = getReadableDatabase();
      int j = Global.getDay(this.mContext);
      if (j == 0)
        j = 7;
      Cursor localCursor = this.mdb.query("t_senior", null, "type= '" + paramString + "'" + " and " + "day" + "= '" + j + "'", null, null, null, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          Logger.d("xjf", "isSeniorNull()--[count]==>" + i);
          return i;
        }
        i++;
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return i;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
    }
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS t_senior(_id INTEGER PRIMARY KEY AUTOINCREMENT,day TEXT, t1 TIME, t2 TIME, type TEXT );");
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
    try
    {
      paramSQLiteDatabase.execSQL("drop table t_senior");
      label6: paramSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS t_senior(_id INTEGER PRIMARY KEY AUTOINCREMENT,day TEXT, t1 TIME, t2 TIME, type TEXT );");
      return;
    }
    catch (Exception localException)
    {
      break label6;
    }
  }

  public String queryMaxTime()
  {
    Object localObject1 = "08:00:00";
    try
    {
      if (this.mdb == null)
        this.mdb = getReadableDatabase();
      if (!this.mdb.isOpen())
        this.mdb = getReadableDatabase();
      int i = Global.getDay(this.mContext);
      if (i == 0)
        i = 7;
      String str1 = "select max(t2) from t_senior where type='1'  and day= '" + i + "'";
      Cursor localCursor = this.mdb.rawQuery(str1, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          return localObject1;
        }
        String str2 = localCursor.getString(0);
        localObject1 = str2;
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return localObject1;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
      Logger.d("xjf", "[maxT2]==>" + (String)localObject1);
    }
  }

  public String queryMinTime()
  {
    Object localObject1 = "08:00:00";
    try
    {
      if (this.mdb == null)
        this.mdb = getReadableDatabase();
      if (!this.mdb.isOpen())
        this.mdb = getReadableDatabase();
      int i = Global.getDay(this.mContext);
      if (i == 0)
        i = 7;
      String str1 = "select min(t1) from t_senior where type='1'  and day= '" + i + "'";
      Cursor localCursor = this.mdb.rawQuery(str1, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          return localObject1;
        }
        String str2 = localCursor.getString(0);
        localObject1 = str2;
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return localObject1;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
      Logger.d("xjf", "[minT1]==>" + (String)localObject1);
    }
  }

  public int querySenior()
  {
    int i = 0;
    try
    {
      SQLiteDatabase localSQLiteDatabase = this.mdb;
      i = 0;
      if (localSQLiteDatabase == null)
        this.mdb = getReadableDatabase();
      boolean bool = this.mdb.isOpen();
      i = 0;
      if (!bool)
        this.mdb = getReadableDatabase();
      int j = Global.getDay(this.mContext);
      if (j == 0)
        j = 7;
      Cursor localCursor = this.mdb.query("t_senior", null, "t1< '" + Global.getTodayTime(this.mContext) + "' " + " and " + "t2" + "> '" + Global.getTodayTime(this.mContext) + "'" + " and " + "day" + "= '" + j + "'", null, null, null, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          Logger.d("xjf", "[count]==>" + i);
          return i;
        }
        i++;
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return i;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
    }
  }

  public int querySenior(String paramString)
  {
    int i = 0;
    try
    {
      SQLiteDatabase localSQLiteDatabase = this.mdb;
      i = 0;
      if (localSQLiteDatabase == null)
        this.mdb = getReadableDatabase();
      boolean bool = this.mdb.isOpen();
      i = 0;
      if (!bool)
        this.mdb = getReadableDatabase();
      int j = Global.getDay(this.mContext);
      if (j == 0)
        j = 7;
      Cursor localCursor = this.mdb.query("t_senior", null, "t1< '" + Global.getTodayTime(this.mContext) + "' " + " and " + "t2" + "> '" + Global.getTodayTime(this.mContext) + "'" + " and " + "day" + "= '" + j + "'" + " and " + "type" + "= '" + paramString + "'", null, null, null, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          Logger.d("xjf", "[count]==>" + i);
          return i;
        }
        i++;
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return i;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.LocalHelper
 * JD-Core Version:    0.6.2
 */